package com.hxit.userserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxit.userserver.dao.UserDao;
import com.hxit.userserver.entity.User;
import com.hxit.userserver.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {
    @Autowired
    UserDao userDao;

    @Override
    public List<User> findUserByMovieId(Integer movieid) {
        return userDao.findUserByMovieId(movieid);
    }


    @Override
    public boolean login(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",user.getUsername());
        User user1 = userDao.selectOne(queryWrapper);
        if (Objects.isNull(user1)){
            System.out.println("账号不存在");
            return false;
        }
        if (Objects.equals(user1.getPassword(),user.getPassword())){
            System.out.println("登录成功");
            return true;
        }
        System.out.println("登录失败");
        return false;
    }
}
